using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using UnityEditor;

public static class BuildExeClientTool
{
    private static string BuildFolder = "Build/EXE/";
    private static string BuildPath = GEditorTool.ProjectPath + BuildFolder;

    [MenuItem("[FC Release]/EXE/生成内网测试应用", false, 0)]
    private static void BuildLocalDebugApk()
    {
        Hashtable appInfo = new Hashtable();
        appInfo["ChannelType"] = BuildClientTool.ChannelType.LocalDebug;
        appInfo["AppName"] = "tafang_localdebug" + "_" + DateTime.Now.ToString("yyyyMMddHHmm") + ".exe";
        appInfo["ChannelName"] = "内网测试";
        appInfo["IsRelease"] = false;
        appInfo["AppVersion"] = "1.0.0";
        appInfo["IsRDG"] = false;
        BuildExeClient(appInfo);
        DebugUtil.Log("生成内网测试包成功");
    }

    private static void BuildExeClient(Hashtable appInfo)
    {
        if (!Directory.Exists(BuildFolder))
            Directory.CreateDirectory(BuildFolder);
        if (!Directory.Exists(BuildClientTool.AppInfoFolder))
            Directory.CreateDirectory(BuildClientTool.AppInfoFolder);

        string buildPath = BuildFolder + appInfo["AppName"];

        BuildClientTool.CreateAppInfo(appInfo);
        BuildClientTool.SetScriptingDefineSymbols(BuildTargetGroup.Standalone, false);
        BuildClientTool.BuildPlayer(buildPath, BuildTarget.StandaloneWindows64);
        BuildClientTool.ClearScriptingDefineSymbols(BuildTargetGroup.Standalone, false);

        Process.Start(BuildPath);
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
    }
}